import { View } from '@tarojs/components';
import { Button } from '@antmjs/vantui';
import { dialog, waitTime } from '@vh-mobile/pro-utils';
import { CSpaceCustom } from '@vh-mobile/pro-components';
import MainContainerCustom from '@/components/MainContainerCustom';

export default function DemoDialog() {
  return (
    <MainContainerCustom>
      <View className="index">
        <CSpaceCustom direction="vertical" align="center">
          <Button
            type="primary"
            block={true}
            onClick={() => {
              dialog.alert(
                '标题',
                '哈哈哈哈我好惨啊哈哈哈哈我好惨啊哈哈哈哈我好惨啊哈哈哈哈我好惨啊',
              );
            }}
          >
            普通提示
          </Button>
          <Button
            type="primary"
            block={true}
            onClick={() => {
              dialog.confirm(
                '标题',
                '哈哈哈哈我好惨啊哈哈哈哈我好惨啊哈哈哈哈我好惨啊哈哈哈哈我好惨啊',
              );
            }}
          >
            确认提示
          </Button>
          <Button
            type="primary"
            block={true}
            onClick={() => {
              dialog.confirm(
                '标题',
                '哈哈哈哈我好惨啊哈哈哈哈我好惨啊哈哈哈哈我好惨啊哈哈哈哈我好惨啊',
                async (action: any) => {
                  if (action === 'confirm') {
                    await waitTime(2000);
                    return false;
                  } else {
                    return true;
                  }
                },
              );
            }}
          >
            异步确认提示
          </Button>
        </CSpaceCustom>
      </View>
    </MainContainerCustom>
  );
}
